import json
import sys
sys.path.append('../')
from matplotlib import pyplot as plt
from matplotlib import gridspec
import matplotlib
from utils import *
f = open('Data/metadata.json')
metadata = json.load(f)
# view metadata present in the file
metadata
{'min_pitch': 165,
'max_pitch': 440,
'start_time': 500,
'end_time': 530,
'vocal_audio_path': 'Data/NIR_VS_Bhoop_Vox.wav',
'mix_audio_path': 'Data/NIR_VS_Bhoop_StereoMix.wav',
'cycle_file': 'Data/NIR_VS_Bhoop_Metre_VilambitEktal.csv',
'tonic': 220,
'notes': [{'label': 'P_', 'cents': -500},
{'label': 'D_', 'cents': -300},
{'label': 'S', 'cents': 0},
{'label': 'R', 'cents': 200},
{'label': 'G', 'cents': 400},
{'label': 'P', 'cents': 700},
{'label': 'D', 'cents': 900},
{'label': "S'", 'cents': 1200},
{'label': "R'", 'cents': 1400},
{'label': "G'", 'cents': 1600},
{'label': "P'", 'cents': 1900}]}
playAudio(metadata['mix_audio_path'], metadata['start_time'], metadata['end_time'])
%%capture
# initialise figure, with 3 subplots
fig, axs = generateFig(3, (14, 7), [2, 3, 3])
# plot waveplot
axs[0] = drawWave(metadata['mix_audio_path'], metadata['start_time'], metadata['end_time'], axs[0], annotate=True, cyclePath=metadata['cycle_file'], numDiv=4)
# plot spetogram
axs[1] = spectogram(metadata['mix_audio_path'], metadata['start_time'], metadata['end_time'], 'Blues', axs[1], yticks=True, annotate=True, cyclePath=metadata['cycle_file'], numDiv=4)
# plot pitch contour
axs[2] = pitchCountour(metadata['vocal_audio_path'], metadata['start_time'], metadata['end_time'], metadata['min_pitch'], metadata['max_pitch'], metadata['notes'], metadata['tonic'], ax=axs[2], annotate=True, cyclePath=metadata['cycle_file'], numDiv=4, xticks=True, yticks=True)
# display figure
fig